{#
/**
 * @file
 * Theme override for a views mini-pager.
 *
 * Available variables:
 * - heading_id: Pagination heading ID.
 * - pagination_heading_level: The heading level to use for the pager.
 * - items: List of pager items.
 *
 * @see template_preprocess_views_mini_pager()
 */
#}

{% if items.previous or items.next %}
  <nav class="flex justify-center" role="navigation" aria-labelledby="{{ heading_id }}">
    <ul class="inline-flex items-center -space-x-px rounded-md text-sm shadow-sm">
      <li>
        <a
          href="{{ items.first.href }}"
          title="{{ 'Go to first page'|t }}"
          rel="prev"
          class="inline-flex items-center space-x-2 rounded-l-md border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
          <span>首页</span>
        </a>
      </li>
      {% if items.previous %}
        <li>
          <a
            href="{{ items.previous.href }}"
            title="{{ 'Go to previous page'|t }}"
            rel="prev"
            class="inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
            <svg
              class="h-5 w-5"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 20 20"
              fill="currentColor"
              aria-hidden="true">
              <path
                fill-rule="evenodd"
                d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z"
                clip-rule="evenodd" />
            </svg>
            <span>上一页</span>
          </a>
        </li>
      {% else %}
        <li
          class="inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
          <svg
            class="h-5 w-5"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 20 20"
            fill="currentColor"
            aria-hidden="true">
            <path
              fill-rule="evenodd"
              d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z"
              clip-rule="evenodd" />
          </svg>
          <span>上一页</span>
        </li>
      {% endif %}

      {# 页码列表（显示5页） #}
      {% for page in items.pager_pages %}
        {% if page.key == items.current %}
          <li
            class="z-10 inline-flex items-center border border-gray-300 bg-gray-100 px-4 py-2 font-medium text-gray-700">
            <span>{{ items.current }}</span>
          </li>
        {% else %}
          <li>
            <a
              href="{{ page.href }}"
              class="inline-flex items-center border border-gray-300 bg-white px-4 py-2 text-gray-500 hover:bg-gray-50"
              title="{{ 'Go to page @key'|t({
                '@key': page.key
              }) }}">
              <span>{{ page.key }}</span>
            </a>
          </li>
        {% endif %}
      {% endfor %}

      {% if items.next %}
        <li>
          <a
            href="{{ items.next.href }}"
            title="{{ 'Go to next page'|t }}"
            rel="next"
            class="inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
            <span>下一页</span>
            <svg
              class="h-5 w-5"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 20 20"
              fill="currentColor"
              aria-hidden="true">
              <path
                fill-rule="evenodd"
                d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
                clip-rule="evenodd" />
            </svg>
          </a>
        </li>
      {% else %}
        <li
          class="inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
          <span>下一页</span>
          <svg
            class="h-5 w-5"
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 20 20"
            fill="currentColor"
            aria-hidden="true">
            <path
              fill-rule="evenodd"
              d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
              clip-rule="evenodd" />
          </svg>
        </li>
      {% endif %}
      <li>
        <a
          href="{{ items.last.href }}"
          title="{{ 'Go to last page'|t }}"
          rel="prev"
          class="inline-flex items-center space-x-2 rounded-r-md border border-gray-300 bg-white px-4 py-2 font-medium text-gray-500 hover:bg-gray-50">
          <span>末页</span>
        </a>
      </li>
    </ul>
  </nav>
{% endif %}
